package com.sky.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sky.dto.AnnouncementsAddDTO;
import com.sky.dto.AnnouncementsUpdateDTO;
import com.sky.dto.BaclstageNoticeQueryDTO;
import com.sky.mapper.BackstageNoticeMapper;
import com.sky.result.PageResult;
import com.sky.service.BackstageNoticeService;
import com.sky.vo.AnnouncementsVO;
import com.sky.vo.UserListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 贾晓晨
 * @version 1.0
 */
@Service
public class BackstageNoticeServiceImp implements BackstageNoticeService {
    @Autowired
    private BackstageNoticeMapper backstageNoticeMapper;

    @Override
    public AnnouncementsVO getNoticeById(Integer id) {
        return backstageNoticeMapper.getNoticeById(id);
    }

    @Override
    public void updateAnnouncement(AnnouncementsUpdateDTO announcementsUpdateDTO) {
        backstageNoticeMapper.updateAnnouncement(announcementsUpdateDTO);
    }

    @Override
    public void deleteAnnouncement(List<Integer> ids) {
        backstageNoticeMapper.deleteAnnouncement(ids);
    }

    @Override
    public void announcementAdd(AnnouncementsAddDTO announcementsAddDTO) {
        backstageNoticeMapper.announcementAdd(announcementsAddDTO);
    }

    @Override
    public PageResult getAllNotice(BaclstageNoticeQueryDTO baclstageNoticeQueryDTO) {
        PageHelper.startPage(baclstageNoticeQueryDTO.getPage(), baclstageNoticeQueryDTO.getPageSize());
        Page<AnnouncementsVO> articleList = backstageNoticeMapper.getAllNotice(baclstageNoticeQueryDTO);
        long total = articleList.getTotal();
        List records = articleList.getResult();
        return new PageResult(total,records);
    }
}
